package cn.edu.scau.cmi.liyetian.multiton;

import java.util.*;

public class Marshal {
	private static List<Marshal> list = new ArrayList<Marshal>();
	private String name;
	private static int count = 0;
	private Marshal(String str) {
		name = str;
	}
	public static Marshal add(String str) {
		if(count == 10) {
			return null;
		}
		else {
			Marshal marsahal = new Marshal(str);
			list.add(marsahal);
			count++;
			return marsahal;
		}
	}
	public static boolean isExist(String str) {
		for(int i = 0;i<list.size();i++) {
//			System.out.println(list.get(i).getName());
			if(str.equals(list.get(i).getName())) {
				
				return true;	
			}
		}
		return false;
	}
	public static boolean isfull() {
		if(count == 10) {
			return true;
		}
		else {
			return false;
		}
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
}
